<?php

namespace app\common\traits;

trait OperatorTrait
{
    protected static function getOperator()
    {
        $request = app('request');
        return $request->adminId;
    }

    public static function onBeforeInsert($model)
    {
        $operator = self::getOperator();
        $model->create_by = $operator;
        $model->create_time = date('Y-m-d H:i:s',time());
    }

    public static function onBeforeUpdate($model)
    {
        $operator = self::getOperator();
        $model->update_by = $operator;
        $model->update_time = date('Y-m-d H:i:s',time());
    }
}